#!/bin/bash

echo "guess a number game start! "

echo "name：TANYE，id：24055060323"

NUM1=$((RANDOM % 100 + 1))

START=1
MAX=7

while [ $START -le $MAX ]; do
  read -p "$START/$MAX: Please input a num(1-100): " NUM2
  
  if [ $NUM2 -gt $NUM1 ]; then
      echo "The number you entered is too big"
  elif [ $NUM2 -lt $NUM1 ]; then
      echo "The number you entered is too small"
  else
      echo "You guessed it right!"
      exit 0
  fi
  
  START=$(( START + 1 ))
done

echo "You lost! The correct number is $NUM1"
exit 0